package leetcode;

public class Code14 {
    public static void main(String[] args) {
        System.out.println(new Code14().longestCommonPrefix(new String[]{
                "flower","flow","flight"
        }));
    }
    public String longestCommonPrefix(String[] strs) {
        if (strs.length==0){
            return "";
        }
        int length = 0;
        go:for (int a=0;a<strs[0].length();a++){
            char item = strs[0].charAt(a);
            for (int b=0;b<strs.length;b++){
                if (strs[b].length()<=a||
                        strs[b].charAt(a)!=item){
                    break go;
                }
            }
            length++;
        }
        return strs[0].substring(0,length);
    }
}
